package com.topnav.mc.admin.entity.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: kenny
 * @Date: 2023/11/13 11:03
 */
public enum FenceAlarmType {
    FENCEIN(1,"进围栏报警"),
    FENCEOUT(2,"出围栏报警");

    private int code;
    private String desc;

    private FenceAlarmType(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {return code;}

    public void setCode(int code) {this.code = code;	}

    public String getDesc() {return desc;}

    public void setDesc(String desc) {this.desc = desc;}

    public static List<EnumModal> toList(){
        List<EnumModal> list = new ArrayList<>();
        for (FenceAlarmType fenceAlarmType : FenceAlarmType.values()) {
            EnumModal enumModal = new EnumModal();
            enumModal.setIndex(fenceAlarmType.ordinal());
            enumModal.setCode(fenceAlarmType.getCode());
            enumModal.setName(fenceAlarmType.name());
            enumModal.setDesc(fenceAlarmType.getDesc());
            list.add(enumModal);
        }
        return list;
    }

    public static FenceAlarmType getByCode(int code) {
        for (FenceAlarmType fenceAlarmType : FenceAlarmType.values()) {
            if (fenceAlarmType.getCode() == code) {
                return fenceAlarmType;
            }

        }
        return null;
    }

    public static String getDescByCode(int code) {
        for (FenceAlarmType fenceAlarmType : FenceAlarmType.values()) {
            if (fenceAlarmType.getCode() == code) {
                return fenceAlarmType.getDesc();
            }

        }
        return null;
    }
}
